#include "mainwindow.h"
#include <QtDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    this->setGeometry(0, 0, 800, 480);

    keySequenceEdit = new QKeySequenceEdit(this);

    keySequenceEdit->setGeometry(350, 200, 150, 30);

    connect(keySequenceEdit,
            SIGNAL(keySequenceChanged(const QKeySequence &)),
            this,
            SLOT(KSEKeySequenceChanged(const QKeySequence &)));
}

MainWindow::~MainWindow()
{
}

void MainWindow::KSEKeySequenceChanged(const QKeySequence &KeySequence)
{
    /* 判断输入的组合键是否为Ctrl + Q，如果是则退出程序 */
    if(KeySequence == QKeySequence(tr("Ctrl+Q"))) {
        /* 结束程序 */
        this->close();
    }else {
        /* 打印出按下的组合键 */
        qDebug()<< KeySequence.toString() <<endl;
    }
}
